package yamen.bdwm.thread;

import yamen.bdwm.MainConstant;
import yamen.bdwm.R;
import yamen.bdwm.compatible.ActionBarActivity;
import android.content.res.Configuration;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.google.analytics.tracking.android.EasyTracker;

public class ThreadActivity extends ActionBarActivity {
	ThreadFragment tf;

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		EasyTracker.getInstance().setContext(this);
		EasyTracker.getInstance().activityStart(this);
	}

	@Override
	protected void onStop() {
		// TODO Auto-generated method stub
		super.onStop();
		EasyTracker.getInstance().activityStop(this);
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.right_f);
		MainConstant.nowActivity = this;
		FragmentTransaction ft = this.getSupportFragmentManager()
				.beginTransaction();
		tf = new ThreadFragment();
		tf.setArguments(this.getIntent().getExtras());
		ft.replace(R.id.right, tf);
		ft.commit();

		String t = this.getIntent().getExtras().getString("title");
		if (t != null)
			if (!t.trim().equals(""))
				setTitle(t);
	}

	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater menuInflater = getMenuInflater();
		menuInflater.inflate(R.menu.thread_menu, menu);
		return super.onCreateOptionsMenu(menu);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.menu_refresh:
			tf.getRefreshed();
			return true;
		}
		return super.onOptionsItemSelected(item);
	}

	@Override
	public void onConfigurationChanged(Configuration newConfig) {

		super.onConfigurationChanged(newConfig);
	}
}
